/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.vrangogym.persistence.entities;

import edu.chl.vrangogym.persistence.entities.enums.MachineType;
import edu.chl.vrangogym.persistence.entities.enums.MachineCondition;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;

/**
 * Entity representing a machine
 * @author habbbe
 * 
 * @revidedBy Ulken (2011-10-16)
 */
@Entity
public class Machine implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    private String name;
    @Enumerated(EnumType.STRING)
    private MachineType machineType;
    @Enumerated(EnumType.STRING)
    private MachineCondition machineCondition;

    /**
     * Instantiate a new Machine
     */
    public Machine() {
    }

    /**
     * Instantiate a new Machine
     * @param name the machine name
     * @param type the machine type
     * @param machineCondition  the condition of the machine
     */
    public Machine(String name, MachineType type, MachineCondition machineCondition) {
        this.name = name;
        this.machineType = type;
        this.machineCondition = machineCondition;
    }

    public MachineCondition getMachineCondition() {
        return machineCondition;
    }

    public void setMachineCondition(MachineCondition machineCondition) {
        this.machineCondition = machineCondition;
    }

    public MachineType getMachineType() {
        return machineType;
    }

    public void setMachineType(MachineType machineType) {
        this.machineType = machineType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Machine other = (Machine) obj;
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "edu.chl.vrangogym.persistence.entities.Machine[ id=" + getName() + " ]";
    }
}
